<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <style>
        *,
        body {
            margin: 0;
            padding: 0;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            flex-direction: column;
            flex-wrap: nowrap;
            background-color: #eee;
            color: #ccc;
        }

        ul,
        li {
            list-style: none;
        }

        a {
            text-decoration: none;
            color: #333;
        }

        a:hover {
            color: lightgreen;
        }

        .box {
            position: absolute;
            border-radius: 5px;
            background: #fff;
            display: flex;
            justify-content: center;
            align-items: center;
            width: 800px;
            height: 500px;
            flex-direction: column;
            flex-wrap: nowrap;
        }

        .content {
            position: relative;
        }

        .content div {
            position: relative;
            width: 400px;
            height: 500px;
            float: left;
            display: flex;
            align-items: center;
            min-height: 500px;
            flex-direction: column;
        }

        .content div img {
            position: absolute;
            top: 40%;
            transform: translateY(-50%);
            width: 100px;
        }

        .content div h3 {
            position: absolute;
            top: 60px;
            font-size: 24px;
            color: #d3b7d8;
        }

        .content div p {
            position: absolute;
            top: 100px;
            font-size: 14px;
        }

        .content div span {
            position: absolute;
            bottom: 120px;
        }

        .content div button {
            position: absolute;
            bottom: 80px;
            color: blueviolet;
            width: 80px;
            height: 30px;
            border-radius: 25px;
            border: 2px double #d3b7d8;
        }

        button:hover {
            background-color: #ddd;
        }

        .mask {
            position: absolute;
            left: 50px;
            /* left: 400px; */
            width: 350px;
            height: 600px;
            border-radius: 10px;
            background: Thistle;
            transition: 1s;
            color: #eee;
            display: flex;
            align-items: center;
            flex-direction: column;
        }

        .mask .login{
            opacity: 1;
            transition: 1s;
        }
        .mask .register{
            opacity: 0;
            transition: 1s;
        }
        .mask h1 {
            position: absolute;
            transform: translateX(-50%);
            top: 25%;
            text-align: center;
            letter-spacing: 10px;
            text-transform: uppercase;
            font-size: 42px;
        }

        .mask input {
            position: absolute;
            transform: translateX(-50%);
            top: 40%;
            border: none;
            background: Thistle;
            color: #eee;
            width: 200px;
            height: 20px;
            line-height: 20px;
            padding: 10px 0 10px 5px;
            border-bottom: 1px solid #eee;
            outline: none;
        }

        .mask ::-webkit-input-placeholder {
            color: #eee;
        }
        .mask input:nth-of-type(2) {
            top: 50%;
        }
        .mask input:nth-of-type(3) {
            top: 60%;
        }
        .mask input:nth-of-type(4) {
            top: 70%;
        }
        .mask button{
            position: absolute;
            transform: translateX(-50%);
            width: 200px;
            height: 50px;
            border-radius: 25px;
            color: DarkOrchid;
            border: 2px double Thistle;
            font-size: 18px;
            letter-spacing: 5px;
        }
        .mask .login button{
            top: 65%;
        }
        .mask .register button{
            top: 85%;
        }
        footer{
            position: fixed;
            color: #333;
            bottom: 5px;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="content">
            <div class="left">
                <h3>点点的前端练习</h3>
                <p>想玩游戏</p>
                <img src="./左.png" alt="">
                <span>已有账号</span>
                <button class="login">去登录</button>
            </div>
            <div class="right">
                <h3>点点的前端练习</h3>
                <p>想玩游戏</p>
                <img src="./右.png" alt="">
                <span>没有账号?</span>
                <button class="register">去注册</button>
            </div>
        </div>
        <div class="mask">
            <div class="login">
                <h1>login</h1>
                <input type="text" placeholder="用户名">
                <input type="password" placeholder="密码">
                <button class="mask_login">登录</button>
            </div>
            <div class="register">
                <h1>register</h1>
                <input type="text" placeholder="用户名">
                <input type="text" placeholder="邮箱">
                <input type="password" placeholder="密码">
                <input type="password" placeholder="确认密码">
                <button class="mask_login">注册</button>
            </div>
        </div>

    </div>
    <footer>&copy;:·.</footer>
    <script>
        var register = document.querySelector('.register')
        var login = document.querySelector('.login')
        var mask = document.querySelector('.mask')
        var inputs = document.querySelectorAll('input')
        var mask_login = document.querySelector('.mask .login')
        var mask_register = document.querySelector('.mask .register')


        register.addEventListener('click', () => {
            mask.style.left = '400px'
            mask_login.style.opacity = 0
            mask_register.style.opacity = 1

        })
        login.addEventListener('click', () => {
            mask.style.left = '50px';
            mask_login.style.opacity = 1
            mask_register.style.opacity = 0
        })
        inputs.forEach(item => {
            item.text = item.placeholder
            item.onfocus = ()=>{
                item.placeholder = ''
            }
            item.onblur = ()=> {
                item.placeholder = item.text
            }
        })
    </script>
</body>

</html>